package com.chlitina.store.common.session;

import java.util.HashMap;

import javax.servlet.http.HttpSession;

public class BoTongSessionContext {
	private static BoTongSessionContext instance;    
    private HashMap<String, HttpSession> map;    
    
    private BoTongSessionContext(){    
        map = new HashMap<String, HttpSession>();    
    }
    
    public static BoTongSessionContext getInstance(){    
        if (instance == null) {    
            instance = new BoTongSessionContext();    
        }    
        return instance;    
    }
    
    public synchronized void AddSession(HttpSession session){    
        if(session!=null){    
            map.put(session.getId(), session);    
        }    
    }   
    
    public synchronized void DelSession(HttpSession session){    
        if(session!=null){    
            map.remove(session.getId());    
        }    
    }   
    
    public synchronized HttpSession getSession(String sessionId){    
        if(sessionId == null){
        	return null;    
        }
        return (HttpSession)map.get(sessionId);    
    }    
}
